/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import POJO.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import ultil.MySqlDataAccessHelper;

/**
 *
 * @author Messi
 */
public class LoaiSanPhamDAO {
    public static ArrayList<LoaiSanPhamPOJO> layDanhSachLoaiSanPham() {
        ArrayList<LoaiSanPhamPOJO> ds = new ArrayList<LoaiSanPhamPOJO>();
        String sql = "SELECT * FROM loaisanpham";
        MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
        helper.open();
        ResultSet rs = helper.executeQuery(sql);
        try {
            while (rs.next()) {
                LoaiSanPhamPOJO lsp = new LoaiSanPhamPOJO(); // ko có tham số truyền vào
                lsp.setMaLoaiSanPham(rs.getInt("maLoaiSanPham"));
                lsp.setTenLoaiSanPham(rs.getString("tenLoaiSanPham"));
                lsp.setMaDanhMuc(rs.getInt("maDanhMuc"));
                lsp.setHinhAnh(rs.getString("hinhAnh"));
                ds.add(lsp);
               
            }
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
        helper.close();
        return ds;
    }
}
